{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collecting keras\n",
      "  Using cached https://files.pythonhosted.org/packages/54/e8/eaff7a09349ae9bd40d3ebaf028b49f5e2392c771f294910f75bb608b241/Keras-2.1.6-py2.py3-none-any.whl\n",
      "Requirement already satisfied: pyyaml in /usr/local/envs/py2env/lib/python2.7/site-packages (from keras)\n",
      "Requirement already satisfied: six>=1.9.0 in /usr/local/envs/py2env/lib/python2.7/site-packages (from keras)\n",
      "Requirement already satisfied: h5py in /usr/local/envs/py2env/lib/python2.7/site-packages (from keras)\n",
      "Requirement already satisfied: scipy>=0.14 in /usr/local/envs/py2env/lib/python2.7/site-packages (from keras)\n",
      "Requirement already satisfied: numpy>=1.9.1 in /usr/local/envs/py2env/lib/python2.7/site-packages (from keras)\n",
      "Installing collected packages: keras\n",
      "Successfully installed keras-2.1.6\n",
      "\u001b[33mYou are using pip version 9.0.3, however version 10.0.1 is available.\n",
      "You should consider upgrading via the 'pip install --upgrade pip' command.\u001b[0m\n"
     ]
    }
   ],
   "source": [
    "!pip install keras"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/envs/py2env/lib/python2.7/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\n",
      "  from ._conv import register_converters as _register_converters\n",
      "Using TensorFlow backend.\n"
     ]
    }
   ],
   "source": [
    "from keras.datasets import mnist\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/envs/py2env/lib/python2.7/site-packages/matplotlib/font_manager.py:1320: UserWarning: findfont: Font family [u'sans-serif'] not found. Falling back to DejaVu Sans\n",
      "  (prop.get_family(), self.defaultFamily[fontext]))\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAATsAAAD7CAYAAAAVQzPHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAGZpJREFUeJzt3X2MVNUZx/HvDEpra0TBCsiLqw2e\nSncV20ippUq1NkhpoFqwVHmppDWppLaxjdbYWuNLaaWmqNhocXkRyosBhNoYbShgCZSg1mYROIiG\n4uIGGkXFV0LZ/rGzl3suO7vzcufO3Tm/T2LmnDkzc5/dfXi8986952RaW1sREal12WoHICKSBBU7\nEfGCip2IeEHFTkS8oGInIl5QsRMRL5xQzpuNMaOB2UAPYK61dmYsUYlUmXK79mRKvc7OGNMD2AVc\nATQDW4FJ1trt8YUnkjzldm0q5zB2OLDbWvuatfYwsBQY19kbMplMayaTad22bVtre7va//kaSxl/\ndx8UldtpzKW0xZNULJ39UcspdgOA10P95txzXaqvry9js/FSLNKBknI7bX+/NMWThljKOWeX6eC5\nTitrU1NT8EOn6TY1xSIRReV2WvMa0hVPtWMpp9g1A4NC/YHAG529oaGhAWj7oTOZjvIpeb7GUu3E\nS7micjuNeQ3piiepWDrL63KK3VZgiDHmbGAf8F3ge2V8nkhaKLdrUMnn7Ky1R4AZwDPADmC5tfbl\nuAITqRbldm0q+dKTkjaW+7bEx93rQiR8GJuOH7oGpDGvIV3xJHgYm3cjuoNCRLygYiciXlCxExEv\nqNiJiBdU7ETECyp2IuIFFTsR8UJZ89mJSG364he/6PRnzJgRtKdMmeKMLVy4MGg/+OCDztiLL75Y\ngehKoz07EfGCip2IeEHFTkS8oHtjO4ilR48eTr9Xr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9Zaw8DS4FxCW4fa+1zwFuRp8cBC3LtBcD4\nhGJpsda+mGsfAnYAA6oVj5SlqrmtvC5MksVuAPB6qN+ce67a+lprW6DtDwWckXQAxpg64EJgSxri\nkaKlMbernkdpy+ski11Hq/54f6+aMeZkYAXwE2vtu9WOR0qi3I5IY14nWeyagUGh/kDgjQS3n89+\nY0x/gNzjgaQ2bIw5kbaEWGytXVnteKRkacxt5XVEksVuKzDEGHO2MaYn8F1gTYLbz2cNMDXXngqs\nTmKjxpgM8Biww1p7f7XjkbKkMbeV1xGJznpijBkD/IG2r+cbrbX3JLbxtu0vAUYBpwP7gTuAJ4Hl\nwGBgLzDBWhs92VuJWEYC/wCaaPuKHuA22s5vJB6PlKeaua28LoymeBIRL+gOChHxgoqdiHhBxU5E\nvKBiJyJeULETES+o2ImIF1TsRMQLKnYi4oX/Axlp3g82o0XwAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f8439dc5890>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# load (downloaded if needed) the MNIST dataset\n",
    "(X_train, y_train), (X_test, y_test) = mnist.load_data()\n",
    "# plot 4 images as gray scale\n",
    "plt.subplot(221)\n",
    "plt.imshow(X_train[0], cmap=plt.get_cmap('gray'))\n",
    "plt.subplot(222)\n",
    "plt.imshow(X_train[1], cmap=plt.get_cmap('gray'))\n",
    "plt.subplot(223)\n",
    "plt.imshow(X_train[2], cmap=plt.get_cmap('gray'))\n",
    "plt.subplot(224)\n",
    "plt.imshow(X_train[3], cmap=plt.get_cmap('gray'))\n",
    "# show the plot\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from keras.datasets import mnist\n",
    "from keras.models import Sequential\n",
    "from keras.layers import Dense\n",
    "from keras.layers import Dropout\n",
    "from keras.layers import Flatten\n",
    "from keras.layers.convolutional import Conv2D\n",
    "from keras.layers.convolutional import MaxPooling2D\n",
    "from keras.utils import np_utils\n",
    "from keras import backend as K\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "X_train1 = X_train[y_train==1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "num_pixels = X_train.shape[1] * X_train.shape[2]\n",
    "X_train = X_train.reshape(X_train.shape[0],num_pixels ).astype('float32')\n",
    "X_test = X_test.reshape(X_test.shape[0],num_pixels).astype('float32')\n",
    "\n",
    "X_train = X_train / 255\n",
    "X_test = X_test / 255"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "y_train = np_utils.to_categorical(y_train)\n",
    "y_test = np_utils.to_categorical(y_test)\n",
    "num_classes = y_train.shape[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train on 60000 samples, validate on 10000 samples\n",
      "Epoch 1/5\n",
      "60000/60000 [==============================] - 4s 66us/step - loss: 0.5001 - acc: 0.8638 - val_loss: 0.2323 - val_acc: 0.9341\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b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\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<keras.callbacks.History at 0x7f83a3dbeed0>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model = Sequential()\n",
    "model.add(Dense(1000, input_dim=num_pixels, activation='relu'))\n",
    "model.add(Dense(num_classes, activation='softmax'))\n",
    "model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])\n",
    "model.fit(X_train, y_train, validation_data=(X_test, y_test), epochs=5, batch_size=1024, verbose=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7f83ae51ff90>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAABHNCSVQICAgIfAhkiAAAAAlwS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AgsB44ATwD/DrwE/AVwELjf3Tt+oqxO\n3zbS/DTe7ehbvWnG99LFfdfi6c+b1pWwi0jn6Qo6kSAUdpEgFHaRIBR2kSAUdpEgFHaRIBR2kSD+\nHyqx2df8ah94AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f83ae569790>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "pic=np.zeros((28,28))\n",
    "pic2=np.copy(pic)\n",
    "for i in range(X_train1.shape[0]):\n",
    "  pic2=X_train1[i,:,:]\n",
    "  pic=pic+pic2\n",
    "pic=(pic/X_train1.shape[0])\n",
    "plt.imshow(pic)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7f83a3e327d0>"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAD7BJREFUeJzt3VuMXdV9x/Hv3IzHnrHx+JKMHYqh\nWH9ASAUUoUiuiqOoEa1AJg+guFIgNErzQB4i4AHxAiiqxEPiFKlVVBIsbCnhIhEKQlHTyg+YvkQk\nqCIE8x8FaszUgy94bI/vHo/7MMfuOdvnrHVmztXz/31e5qyzzt6zvO2f9zn7f9ZePRcuXEBEFr7e\nTg9ARNpDYRcJQmEXCUJhFwlCYRcJor/Nv0+X/kVar6fakw2F3czuAp4F+oCfu/szjexPRFqnZ751\ndjPrA8aAvwbGgXeALe7+QWIzndlFWq/qmb2Rz+x3AH9y94/d/SzwErC5g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J\nQmEXCUJhFwkie8PJJtMavSIdojO7SBAKu0gQCrtIEAq7SBAKu0gQCrtIEAq7SBDtrrMDYGZ3Ac8C\nfcDP3f2ZToyjGjPbA0wB54Fpd/9yB8eyDbgbOHBxtR0zGwFeBtYze7/+++tYY69dY3uKuS/j3Yqx\n1VpmvKPHrsnLn89Z28/sZtYH/AvwN8DNwBYzu7nd48j4qrvf2smgl7wA3FV47nFgp7tvAHaW2p3w\nApePDeAnpWN3ayeCXjLN7EKjNwFfAR4u/Rvr9LGrNS5ow3HrxNv4O4A/ufvH7n4WeAnY3IFxdD13\n3wUcLjy9GdheerwduLetgyqpMbau4O4T7v5u6fEUcHGZ8Y4eu8S42qITYV8HfFrWHqe71nu/APyH\nmf3ezP6h04Op4gsXl9kq/VzT4fEUfd/M3jOzbWa2otODKS06ehvwW7ro2BXGBW04bp0Ie7Xvx3fT\nslAb3f12Zj9mPGxmf9XpAV1BumoZ7yrLjHeFTi1/3omwjwPXlLW/BOzrwDiqcvd9pZ8HgNeY/djR\nTfZfXEG39PNAh8dzibvvd/fz7j4D/IwOHrvSMuOvAr9w91+Vnu74sas2rnYdt06E/R1gg5ldZ2aL\ngG8Cb3RgHJcxs6VmNnzxMfB1um8p6jeAB0uPHwRe7+BYKnTLMt61lhmnw8eu08uft3sVVwDM7G+B\nf2K29LbN3f+x7YOowsyuZ/ZsDrNlyV92cmxm9iKwCVgF7AeeBP4NeAX4M2AvcJ+7t/1CWY2xbWLu\ny3i3Ymy1lhn/LR08dk1e/nzOOhJ2EWk/fYNOJAiFXSQIhV0kCIVdJAiFXSQIhV0kCIVdJIj/Aw1Q\n6+OobAkfAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f83ae509610>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "for i in range(pic.shape[0]):\n",
    "  if i<20:\n",
    "    pic[:,i]=pic[:,i+1]\n",
    "plt.imshow(pic)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0., 0., 0., 0., 0., 0., 0., 0., 1., 0.]], dtype=float32)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.predict(pic.reshape(1,784))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "pic=np.zeros((28,28))\n",
    "pic2=np.copy(pic)\n",
    "for i in range(X_train1.shape[0]):\n",
    "  pic2=X_train1[i,:,:]\n",
    "  pic=pic+pic2\n",
    "pic=(pic/X_train1.shape[0])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0., 1., 0., 0., 0., 0., 0., 0., 0., 0.]], dtype=float32)"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.predict(pic.reshape(1,784))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7f8439d32690>"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAD4NJREFUeJzt3V2MnNV9x/Hv2us37F2/k6wdakOx\nDlhI5SVCkVxVRFEjWoEgF6BQKSI0SiPkXESFC8QNoKgSF3kpUhEqCQgjJbxIhIJQ1L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053d0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "pic=np.zeros((28,28))\n",
    "pic2=np.copy(pic)\n",
    "for i in range(X_train1.shape[0]):\n",
    "  pic2=X_train1[i,:,:]\n",
    "  pic=pic+pic2\n",
    "pic=(pic/X_train1.shape[0])\n",
    "pic2=np.copy(pic)\n",
    "for i in range(pic.shape[0]):\n",
    "  if ((i>6) & (i<26)):\n",
    "    pic[:,i]=pic2[:,(i-1)]\n",
    "plt.imshow(pic)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0., 1., 0., 0., 0., 0., 0., 0., 0., 0.]], dtype=float32)"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.predict(pic.reshape(1,784))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7f83a3ebccd0>"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAD3VJREFUeJzt3V2MnNV9x/HvYnuxsb3GaxuwHWpD\nsQ4vlgooQpFcKqKoEa1AkAtQqFQRGqW5IBdR4QIhIUCoEhd5KVKrqCQgjJTwIhEKQlHSyjd2byIS\nVBHz8rcCtY1rY8fYxubFxut1L3a8mh3PnGd2Z2Zn1uf7udnnzNnn2bNj//aZef5znjN0+vRpJJ37\nzuv3ACTNDsMu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IYdqkQhl0qhGGXClF5\nw8kuK3YNXanfPLNLhTDsUiEMu1QIwy4VwrBLhTDsUiEMu1SI2a6zA5BSuhl4ApgH/CwiHu/HOJpJ\nKe0EjgGngLGI+HIfx/I0cAtw4MxqOymlUeAFYD0T9+u/s4019mZrbI8w/WW8ezG2VsuM9/W56/Ly\n59M262f2lNI84N+AvwGuBu5KKV092+Oo8NWIuLafQa95Bri54bEHgC0RsQHYUmv3wzOcPTaAH9ee\nu2v7EfSaMSYWGr0K+Apwb+3/WL+fu1bjgll43vrxMv4G4I8R8X5EfAE8D9zWh3EMvIjYChxqePg2\nYHNtezNw+6wOqqbF2AZCROyLiDdq28eAM8uM9/W5y4xrVvQj7GuBD+raexis9d5PA/+ZUvp9Sukf\n+z2YJi4+s8xW7etFfR5Po++llN5MKT2dUlre78HUFh29DvgtA/TcNYwLZuF560fYm30+fpCWhdoU\nEdcz8Tbj3pTSX/V7QHPIQC3j3WSZ8YHQr+XP+xH2PcClde0vAXv7MI6mImJv7esB4GUm3nYMkv1n\nVtCtfT3Q5/FMioj9EXEqIsaBn9LH5662zPhLwM8j4pe1h/v+3DUb12w9b/0I++vAhpTSZSmlYeCb\nwKt9GMdZUkqLU0pLz2wDX2fwlqJ+Fbi7tn038EofxzLFoCzj3WqZcfr83PV7+fPZXsUVgJTS3wL/\nwkTp7emI+OdZH0QTKaXLmTibw0RZ8hf9HFtK6TngJmAlsB94GPgP4EXgz4DdwB0RMesXylqM7Sam\nv4x3L8bWapnx39LH567Ly59PW1/CLmn2+Qk6qRCGXSqEYZcKYdilQhh2qRCGXSqEYZcK8f/MiQBu\nfbGsLQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f83a3e5ead0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "pic=np.zeros((28,28))\n",
    "pic2=np.copy(pic)\n",
    "for i in range(X_train1.shape[0]):\n",
    "  pic2=X_train1[i,:,:]\n",
    "  pic=pic+pic2\n",
    "pic=(pic/X_train1.shape[0])\n",
    "pic2=np.copy(pic)\n",
    "for i in range(pic.shape[0]):\n",
    "  if ((i>6) & (i<26)):\n",
    "    pic[:,i]=pic2[:,(i-2)]\n",
    "plt.imshow(pic)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0., 0., 0., 1., 0., 0., 0., 0., 0., 0.]], dtype=float32)"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.predict(pic.reshape(1,784))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.15"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
